<?php
error_reporting(0);
ini_set("magic_quotes_runtime", 0);
ini_set("date.timezone", "PRC");
ini_set('memory_limit', '840M');
ini_set('default_charset', 'utf-8');
define('adminfile', 'ydbsupervise');
define('admin_ClassURL', 'http://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/')));
define('admin_URL', str_replace(adminfile, '', admin_ClassURL));
$urlinfo = parse_url(admin_URL);
define('admin_PATH', $urlinfo['path']);
define('admin_http', $urlinfo['host']);
define('admin_ROOT', substr(__FILE__, 0, strrpos(__FILE__, adminfile)));
define('admin_DIR', pathinfo(__FILE__, PATHINFO_DIRNAME));
define('admin_FROM', false);
define('admin_AGENT', $_SERVER['HTTP_USER_AGENT']);  //客户端IP
require admin_ROOT . 'datacache/public.php';   //数据库相关配置文件
require admin_ROOT . 'public/class_connector.php'; //初始化系统类
$point = indexget('point', 'R');
$point = empty($point) ? 'admin' : $point;
$archive = indexget('archive', 'R');
$archive = empty($archive) ? 'adminuser' : $archive;
$action = indexget('action', 'R');
$action = empty($action) ? 'login' : $action;
$soft_MOD = array('admin', 'public', 'product', 'forum', 'filemanage', 'basebook', 'member', 'order', 'other', 'news', 'inc', 'cache', 'bann', 'logs', 'template');

if (in_array($point, $soft_MOD)) {
	include admin_ROOT . adminfile . "/control/$archive.php";
	$control = new important();
	$action = 'on' . $action;
	if (method_exists($control, $action)) {
		$control->$action();
	} else {
		exit('错误：系统方法错误！');
	}
} else {
	exit('错误：系统对象错误');
}

function indexget($k, $var='R', $htmlcode=true) {
	switch ($var) {
		case 'G':
			$var = &$_GET;
			break;
		case 'P':
			$var = &$_POST;
			break;
		case 'C':
			$var = &$_COOKIE;
			break;
		case 'R':
			$var = &$_GET;
			if (empty($var[$k])) {
				$var = &$_POST;
			}
			break;
	}
	$putvalue = isset($var[$k]) ? indexdaddslashes($var[$k], 0) : NULL;
	return $htmlcode ? indexhtmldecode($putvalue) : $putvalue;
}

function indexdaddslashes($string, $force=0, $strip=FALSE) {
	if (!get_magic_quotes_gpc() || $force == 1) {
		if (is_array($string)) {
			foreach ($string as $key => $val) {
				$string[$key] = addslashes($strip ? stripslashes($val) : $val);
			}
		} else {
			$string = addslashes($strip ? stripslashes($string) : $string);
		}
	}
	return $string;
}

function indexhtmldecode($str) {
	if (empty($str)) return $str;
	if (!is_array($str)) {
		$str = htmlspecialchars(trim($str));
		$str = str_ireplace("Xss", "", $str);
	} else {
		foreach ($str as $key => $val) {
			$str[$key] = htmlspecialchars($val);
			$str[$key] = indexhtmldecode($val);
		}
	}
	return $str;
}
?>